
package com.yibei.currentutils.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * @author hubert <yufengzhang189@dingtalk.com>
 * @since 0.0.1
 * @see 需要将工具包加入扫描器当中,否则不生效
 * @see boot应用方式: @ComponentScan(basePackages = {"com.yibei.currentutils"})
 * @see mcv引用方式: context:component-scan base-package="com.yibei.currentutils"
 * */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CurrentLimit {

    /**
     *@see选择限流类型
     */
    String switc() default CurrentCommon.currentLimitSwitcBucket;

    /**
     *@see配置刷新时间间隔
     */
    long refreshInterval() default CurrentCommon.refreshIntervalDefault;

    /**
     *@see允许最大流量
     */
    int capacity() default CurrentCommon.capacity;

    /**
     *@see流速
     */
    int allowQuota() default CurrentCommon.allowQuota;

    /**
     *@see单位时间：秒
     */    
    int perSecond() default CurrentCommon.perSecond;

    /**
     *@see是否开启限流
     */
    boolean isopen() default true;
}

class CurrentCommon {

    public static final String currentLimitSwitcBucket = "bucket";

    public static final String currentLimitSwitcToken = "token";

    public static final long refreshIntervalDefault = 1800000;

    public static final int capacity = 50;

    public static final int allowQuota = 50;

    public static final int perSecond = 1;

    private CurrentCommon() {

    }
}